﻿using FluentValidation.Attributes;
using Logistics.Web.Models.Common;
using Logistics.Web.Validators;
using Nop.Web.Framework;
using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace Logistics.Web.Models.Order
{
    [Validator(typeof(OrderLocationValidator))]
    public class OrderLocationModel
    {
        public OrderLocationModel()
        {
            Packages = new List<OrderPackageModel>();
            Addresses = new List<SelectListItem>();
            Regions = new List<SelectListItem>();
            RegionStateProvinceMap = new List<RegionStateProvice>();
            AvailableUserAddrStateProvinces = new List<SelectListItem>();
            AvailableAddressStateProvinces = new List<SelectListItem>();
        }

        public int Id { get; set; }

        public AddressModel UserAddress { get; set; }
        public int? SelectedUserAddressId { get; set; }
        public bool IsUserAddressTypeVerified { get; set; }
        public bool IsUserAddressPickup { get; set; }
        public AddressModel Address { get; set; }
        public int? SelectedAddressId { get; set; }
        public List<SelectListItem> Addresses { get; set; }
        public bool IsAddressTypeVerified { get; set; }

        public int SelectedRegionId { get; set; }
        public List<SelectListItem> Regions { get; set; }
        public List<RegionStateProvice> RegionStateProvinceMap { get; set; }

        public List<SelectListItem> AvailableUserAddrStateProvinces { get; set; }
        public List<SelectListItem> AvailableAddressStateProvinces { get; set; }

        [NopResourceDisplayName("Logistics.Order.PackageNumber")]
        public int PackageNumber { get; set; }
        public bool? IsExpress { get; set; }
        //public bool LocationEdit { get; set; }

        public List<OrderPackageModel> Packages { get; set; }

        public decimal StandardSize { get; set; }
        public decimal MaxSize { get; set; }
        public decimal MaxSingleSize { get; set; }
        public decimal StandardWeight { get; set; }
        public decimal MaxWeight { get; set; }
        public decimal OverSizeCharge { get; set; }
        public decimal OverWeightCharge { get; set; }
        public int MaxPackageNumber { get; set; }

        public bool? NoSignature { get; set; }
        public bool CanDeliverOnSat { get; set; }
        public bool CanDeliverOnSun { get; set; }
        public bool HasInsuranceOnPackages { get; set; }

        public DateTime? PickupDate { get; set; }
        public int? PickupTimeWindowId { get; set; }

        public bool ResetPickupTime { get; set; }

        public List<string> AvaliablePickupDates { get; set; }
        public List<string> AvaliablePickupTimeWindows { get; set; }

        public PickupDateTimeWindow[,] AvaliablePickupDateTimeWindows { get; set; }

        [AllowHtml]
        public string AdditionalInstruction { get; set; }

        public class PickupDateTimeWindow
        {
            public DateTime PickupDate { get; set; }
            public int PickupTimeWindow { get; set; }
            public bool CanSelect { get; set; }
            public bool Selected { get; set; }
        }

        public class RegionStateProvice
        {
            public int RegionId { get; set; }
            public int StateProvinceId { get; set; }
            public string StateProvinceName { get; set; }
        }
    }
}